home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 6 / MacMania 6.toast / / Multimedia & Desktop / sk8 / SK8InJava / Code / Media / Sound.java
Encoding:
Java Source  |  1997-02-27  |  1.1 KB  |  59 lines  |  [TEXT/CWIE]

  1. /*  SK8 © 1997 Apple Computer, Inc.
  2.     This code is protected under the current SK8 License
  3.     See http://sk8.research.apple.com/ for more information
  4.     Apple Research Laboratories
  5. */
  6.  
  7.  
  8. import java.applet.*;
  9.  
  10. // Very simple sound playing utility. Assumes a sound file of extension .au exists
  11. // in a folder called Media where the code base is. 
  12.  
  13. class soundrsrc {
  14.     // slots.
  15.     
  16.     private AudioClip mediadataVar;
  17.     public String fileVar;
  18.     
  19.     // Constructor.
  20.     
  21.     soundrsrc (String file) {
  22.         this.fileVar = file;
  23.     }
  24.     
  25.     // Methods.
  26.  
  27.     public String file () {
  28.         return this.fileVar;
  29.     }
  30.     
  31.     public void setfile (String newvalue) {
  32.         this.fileVar = newvalue;
  33.     }
  34.  
  35.     public void loadmedia () {
  36.         if (this.mediadataVar == null) 
  37.             this.mediadataVar = sk8.currentApplet.getAudioClip(sk8.currentApplet.getDocumentBase(), this.fileVar);
  38.     }
  39.     
  40.     public void unloadmedia () {
  41.         this.mediadataVar = null;
  42.     }
  43.     
  44.     public void play () {
  45.         this.loadmedia();
  46.         this.mediadataVar.play();
  47.     }
  48.  
  49.     public void stop () {
  50.         this.loadmedia();
  51.         this.mediadataVar.stop();
  52.     }
  53.  
  54.     public void loop () {
  55.         this.loadmedia();
  56.         this.mediadataVar.loop();
  57.     }
  58.  
  59. }